#!/usr/local/bin/python
# -*- coding: utf-8 -*-
from django.db import models
from assoce.core.models import *

class RessourceManager(models.Model):
    activite = models.ForeignKey(Activite, related_name='ressource_mgrs', verbose_name='Activité gérant des ressources')
    def __unicode__(self):
        return self.activite.label
    
class Ressource(models.Model):
    ref = models.CharField(max_length=50, verbose_name='numéro série', unique=True)
    item = models.OneToOneField(Item, primary_key=True, verbose_name='nom', limit_choices_to={'activite__ressource_mgrs__isnull':False})
    rent = models.DecimalField(max_digits=4, decimal_places=2, verbose_name='prix location', help_text='pour la période définie par l\'activité')
    
    def reserver_link(self):
        return '<a href=reserver/%d>réserver</a>' % self.item.id
    reserver_link.allow_tags = True
    reserver_link.short_description = 'réservation'

    def selec_link(self):
        return '<input type=checkbox name=%d>' % self.item.id
    selec_link.allow_tags = True
    selec_link.short_description = 'sélection'
    def __unicode__(self):
        return self.item.label
